Computing devices perform tasks by executing computing instructions. A set of computing instructions for performing a particular task form a function. A set of functions that interact for performing related tasks form an application. Two or more different applications may need to use the same function to perform the same particular task. While it is possible to include the same function's computing instructions in each of the different applications, it is more efficient for each application to use the same function. By using the same function, less memory is used to store instructions and modifications to the function need only be made in one place.
To allow more than one application to use the same functions, a library of functions, i.e., a library, is formed. Typically, a function's computing instructions and a reference to the computing instructions is placed in a library. This is done for each of the functions in a library. An application uses a function in a library, i.e., a library function, by calling the function using the reference.
Typically, libraries are loaded by a library loader software module in an operating system of a computing device. The library loader stores a reference count that is a record of how many software modules, e.g., applications and libraries, refer to a library. For example, a first application passes a request to a library loader to load a library. The library loader loads and initializes the library, passes a reference for the library to the application, and increments the reference count for the library to one. If a second application passes a request to the library loader to load the library, the library is not loaded and initialized again. Instead, the second application receives a reference for the library and the reference count for the library is incremented to two. If either of the two applications passes a request to the library loader to unload the library, the reference count is decremented. The library remains loaded until the reference count is decremented to zero at which time the library is unloaded from memory.
In general, after a library is first loaded and initialized, each subsequent load request for the library causes the library's reference count to be incremented and each unload request causes the library's reference count to be decremented. Using reference counts reduces the number of times software modules, i.e., libraries, must be loaded and unloaded. The computing resources, e.g., processor time, memory, disc access, etc., that would have been used for loading and unloading can be made available for other tasks.